package com.guangdujs.kis.controller;

import java.math.BigDecimal;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.guangdujs.common.annotation.Log;
import com.guangdujs.common.core.controller.BaseController;
import com.guangdujs.common.core.domain.AjaxResult;
import com.guangdujs.common.enums.BusinessType;
import com.guangdujs.kis.domain.Vwicbill32;
import com.guangdujs.kis.service.IVwicbill32Service;
import com.guangdujs.common.utils.poi.ExcelUtil;
import com.guangdujs.common.core.page.TableDataInfo;

/**
 * 销售订单Controller
 * 
 * @author kis
 * @date 2022-11-04
 */
@RestController
@RequestMapping("/kis/Vwicbill32")
public class Vwicbill32Controller extends BaseController
{
    @Autowired
    private IVwicbill32Service vwicbill32Service;

    /**
     * 查询销售订单列表
     */
    @PreAuthorize("@ss.hasPermi('kis:Vwicbill32:list')")
    @GetMapping("/list")
    public TableDataInfo list(Vwicbill32 vwicbill32)
    {
        startPage();
        List<Vwicbill32> list = vwicbill32Service.selectVwicbill32List(vwicbill32);
        BigDecimal money = vwicbill32Service.selectAllAmount(vwicbill32);
        return getDataTable(list, money);
    }

    @GetMapping("/selectFourMoney")
    public AjaxResult selectFourMoney(){
        return AjaxResult.success(vwicbill32Service.selectFourMoney());
    }

    /**
     * 根据时间范围获取客户名称列表
     */
    @GetMapping("/selectFcustidnameList")
    public AjaxResult selectFcustidnameList(Vwicbill32 vwicbill32){
        return AjaxResult.success(vwicbill32Service.selectFcustidnameList(vwicbill32));
    }

    /**
     * 根据时间范围获取负责人列表
     */
    @GetMapping("/selectFmangeridnameList")
    public AjaxResult selectFmangeridnameList(Vwicbill32 vwicbill32){
        return AjaxResult.success(vwicbill32Service.selectFmangeridnameList(vwicbill32));
    }

    /**
     * 根据时间范围获取业务员列表
     */
    @GetMapping("/selectFempidnameList")
    public AjaxResult selectFempidnameList(Vwicbill32 vwicbill32){
        return AjaxResult.success(vwicbill32Service.selectFempidnameList(vwicbill32));
    }

    /**
     * 根据时间范围获取产品名称列表
     */
    @GetMapping("/selectFitemnameList")
    public AjaxResult selectFitemnameList(Vwicbill32 vwicbill32){
        return AjaxResult.success(vwicbill32Service.selectFitemnameList(vwicbill32));
    }

    /**
     * 导出销售订单列表
     */
    @PreAuthorize("@ss.hasPermi('kis:Vwicbill32:export')")
    @Log(title = "销售订单", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Vwicbill32 vwicbill32)
    {
        List<Vwicbill32> list = vwicbill32Service.selectVwicbill32List(vwicbill32);
        ExcelUtil<Vwicbill32> util = new ExcelUtil<Vwicbill32>(Vwicbill32.class);
        util.exportExcel(response, list, "销售订单数据");
    }

    /**
     * 获取当前月每天的销售额
     */
    @GetMapping("/selectMonthMoneyList")
    public AjaxResult selectMonthMoneyList(){
        return AjaxResult.success(vwicbill32Service.selectMonthMoneyList());
    }

    /**
     * 获取当前季度的每月销售额
     */
    @GetMapping("/selectQuarterMoneyList")
    public AjaxResult selectQuarterMoneyList(){
        return AjaxResult.success(vwicbill32Service.selectQuarterMoneyList());
    }

    /**
     * 获取当前年的每月销售额
     */
    @GetMapping("/selectYearMoneyList")
    public AjaxResult selectYearMoneyList(){
        return AjaxResult.success(vwicbill32Service.selectYearMoneyList());
    }

    @GetMapping("/selectTopFItemNames")
    public AjaxResult selectTopFItemNames(){
        return AjaxResult.success(vwicbill32Service.selectTopFItemNames());
    }

    @GetMapping("/selectTopFCustIDNames")
    public AjaxResult selectTopFCustIDNames(){
        return AjaxResult.success(vwicbill32Service.selectTopFCustIDNames());
    }

    @GetMapping("/selectTopProvince")
    public AjaxResult selectTopProvince(){
        return AjaxResult.success(vwicbill32Service.selectTopProvince());
    }
}
